<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>耗材新增</title>
    <meta charset="utf-8">
    <!-- Bootstrap Core CSS -->
    <link href="${css}/bootstrap.min.css" rel="stylesheet"/>
    <!-- bootstrapValidator验证 -->
    <link href="${assets}/bootstrapValidator/css/bootstrapValidator.css" rel="stylesheet"/>
</head>
<body style="width: 98%">
    <form id="myForm" class="form-horizontal" method="post" >
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">名称</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="name" name="name"
                       placeholder="请输入名称">
            </div>
        </div>
        <div class="form-group">
            <label for="kind" class="col-sm-2 control-label">类别</label>
            <div class="col-sm-10">
                <select id="kind" name="kind" class="form-control">
                    <option value="1" >试剂</option>
                    <option value="2" >耗材</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="brand" class="col-sm-2 control-label">品牌</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="brand" name="brand"
                       placeholder="请输入品牌">
            </div>
        </div>
        <div class="form-group">
            <label for="spec" class="col-sm-2 control-label">规格</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="spec" name="spec"
                       placeholder="请输入规格">
            </div>
        </div>
        <div class="modal-footer" style="text-align: center ">
            <button type="button" class="btn btn-default" data-dismiss="modal" id="closeModalButt">关闭</button>
            <button type="submit" class="btn btn-primary">保存</button>
        </div>
    </form>

    <!-- jQuery -->
    <script src="${js}/jquery-1.9.1.min.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="${js}/bootstrap.min.js"></script>

    <script src="${js}/bootbox.js"></script>
    <!-- bootstrapValidator验证 -->
    <script src="${assets}/bootstrapValidator/js/bootstrapValidator.js"></script>
    <!-- bootstrapValidator验证 国际化中文 -->
    <script src="${assets}/bootstrapValidator/js/language/zh_CN.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            $('#myForm').bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    name: {
                        validators: {
                            notEmpty: true
                        }
                    }
                }
            }).on('success.form.bv', function (e) {
                e.preventDefault();
                $.ajax({
                    url:'${URL_ADM_REAGENTCONSUMABLE_ADD}',
                    type:'post',
                    data:$('#myForm').serialize(),
                    async : false, //默认为true 异步
                    error:function(){
                        alert('error');
                    },
                    success:function(data){
                        window.parent.closeModal("add");
                    }
                });
            });

            $("#closeModalButt").on("click",function(){
                window.parent.simpleCloseModal("add");
            });

        });

        <%--function doAdd(){--%>
            <%--$.ajax({--%>
                <%--url:'${URL_ADM_REAGENTCONSUMABLE_ADD}',--%>
                <%--type:'post',--%>
                <%--data:$('#myForm').serialize(),--%>
                <%--async : false, //默认为true 异步--%>
                <%--error:function(){--%>
                    <%--alert('error');--%>
                <%--},--%>
                <%--success:function(data){--%>
                    <%--window.parent.closeModal("add");--%>
                <%--}--%>
            <%--});--%>
        <%--}--%>

    </script>
</body>
</html>